home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-09-28 | 5.3 KB | 244 lines | [TEXT/CWIE] |
- /*
- A window that provides the user interface for editing preferences.
-
- Created 29 Jan 1996 by EGH
-
- Copyright © 1996, Apple Computer, Inc. All rights reserved.
- */
-
- #include <QuickTimeComponents.h>
-
- #include <String_Utils.h>
-
- #include "CKeyFilters.h"
- #include "CUtils.h"
-
- #include "CPrefsWindow.h"
-
- // =========
- // constants
-
- const PaneIDT Button_Okay = 'okay';
- const PaneIDT Button_Cancel = 'canc';
- const PaneIDT Button_Compression = 'comp';
- const PaneIDT Caption_Compression = 'coms';
- const PaneIDT Edit_Width = 'widt';
- const PaneIDT Edit_Height = 'heig';
- const PaneIDT Edit_TileSuffix = 'tile';
- const PaneIDT Edit_MovieSuffix = 'move';
- const PaneIDT Check_ReplaceFiles = 'dele';
- const PaneIDT Edit_Pan = 'pan ';
- const PaneIDT Edit_Tilt = 'tilt';
- const PaneIDT Edit_Zoom = 'zoom';
-
- // =========
-
-
- //static
- CPrefsWindow *CPrefsWindow::CreatePrefsWindowWindowStream(
- LStream *inStream)
- {
- return new CPrefsWindow(inStream);
- }
-
- CPrefsWindow::CPrefsWindow(
- LStream *inStream) :
- LDialogBox(inStream)
- {
- mPrefsHdl = gApp->GetPreferences();
- ThrowIfNil_(mPrefsHdl);
-
- mSpatialQuality = (*mPrefsHdl)->spatialQuality;
- mDepth = (*mPrefsHdl)->depth;
- mCodec = (*mPrefsHdl)->codec;
- }
-
- CPrefsWindow::~CPrefsWindow()
- {
- }
-
- void CPrefsWindow::FinishCreateSelf()
- {
- LDialogBox::FinishCreateSelf();
- AddAttachment(new LUndoer); // for the edits
-
- SetValueForPaneID(Edit_Width, (*mPrefsHdl)->width);
- SetValueForPaneID(Edit_Height, (*mPrefsHdl)->height);
-
- LPane *pane = FindPaneByID(Edit_TileSuffix);
- if (pane != nil)
- {
- pane->SetDescriptor((*mPrefsHdl)->tileSuffix);
- }
- pane = FindPaneByID(Edit_MovieSuffix);
- if (pane != nil)
- {
- pane->SetDescriptor((*mPrefsHdl)->movieSuffix);
- }
-
- Str255 valueStr;
- LEditField *edit = (LEditField *)FindPaneByID(Edit_Pan);
- if (edit != nil)
- {
- edit->SetKeyFilter(CKeyFilters::RealNumberFieldPositive);
- FixedToStr((*mPrefsHdl)->pan, valueStr);
- edit->SetDescriptor(valueStr);
- }
- edit = (LEditField *)FindPaneByID(Edit_Tilt);
- if (edit != nil)
- {
- edit->SetKeyFilter(CKeyFilters::RealNumberField);
- FixedToStr((*mPrefsHdl)->tilt, valueStr);
- edit->SetDescriptor(valueStr);
- }
- edit = (LEditField *)FindPaneByID(Edit_Zoom);
- if (edit != nil)
- {
- edit->SetKeyFilter(CKeyFilters::RealNumberFieldPositive);
- FixedToStr((*mPrefsHdl)->zoom, valueStr);
- edit->SetDescriptor(valueStr);
- }
-
- // find and listen to the buttons
- LButton *button;
- button = (LButton *)FindPaneByID(Button_Okay);
- ThrowIfNil_(button);
- button->AddListener(this);
-
- button = (LButton *)FindPaneByID(Button_Cancel);
- ThrowIfNil_(button);
- button->AddListener(this);
-
- button = (LButton *)FindPaneByID(Button_Compression);
- ThrowIfNil_(button);
- button->AddListener(this);
-
- LStdCheckBox *check = (LStdCheckBox *)FindPaneByID(Check_ReplaceFiles);
- ThrowIfNil_(check);
- check->SetValue((*mPrefsHdl)->replaceFiles);
-
- SetCompressionText(FindPaneByID(Caption_Compression), mCodec, mSpatialQuality);
- }
-
-
- /* CPrefsWindow::ListenToMessage
-
- Listen in on what is happening in the user interface.
- */
- void CPrefsWindow::ListenToMessage(
- MessageT inMessage,
- void *ioParam)
- {
- switch (inMessage)
- {
- case Button_Okay:
- {
- (*mPrefsHdl)->codec = mCodec;
- (*mPrefsHdl)->depth = mDepth;
- (*mPrefsHdl)->spatialQuality = mSpatialQuality;
-
- LPane *pane;
- pane = FindPaneByID(Edit_TileSuffix);
- if (pane != nil)
- pane->GetDescriptor((*mPrefsHdl)->tileSuffix);
- pane = FindPaneByID(Edit_MovieSuffix);
- if (pane != nil)
- pane->GetDescriptor((*mPrefsHdl)->movieSuffix);
-
- Str255 valueStr;
- pane = FindPaneByID(Edit_Pan);
- if (pane != nil)
- {
- pane->GetDescriptor(valueStr);
- (*mPrefsHdl)->pan = StrToFixed(valueStr);
- }
- pane = FindPaneByID(Edit_Tilt);
- if (pane != nil)
- {
- pane->GetDescriptor(valueStr);
- (*mPrefsHdl)->tilt = StrToFixed(valueStr);
- }
- pane = FindPaneByID(Edit_Zoom);
- if (pane != nil)
- {
- pane->GetDescriptor(valueStr);
- (*mPrefsHdl)->zoom = StrToFixed(valueStr);
- }
-
- (*mPrefsHdl)->width = GetValueForPaneID(Edit_Width);
- (*mPrefsHdl)->height = GetValueForPaneID(Edit_Height);
-
- (*mPrefsHdl)->replaceFiles = GetValueForPaneID(Check_ReplaceFiles) != 0;
-
- // fall through
- }
-
- case Button_Cancel:
- delete this;
- break;
-
- case Button_Compression:
- {
- ComponentInstance ci =
- ::OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
- ThrowIfNil_(ci);
-
- try
- {
- ComponentResult result;
-
- SCSpatialSettings ss;
- ss.codecType = mCodec;
- ss.spatialQuality = mSpatialQuality;
- ss.depth = mDepth;
- ss.codec = nil;
- result = ::SCSetInfo(ci, scSpatialSettingsType, &ss);
- ThrowIf_(result < 0);
-
- result = ::SCRequestImageSettings(ci);
- ThrowIf_(result < 0);
-
- if (result != scUserCancelled)
- {
- result = ::SCGetInfo(ci, scSpatialSettingsType, &ss);
- ThrowIf_(result < 0);
- mCodec = ss.codecType;
- mSpatialQuality = ss.spatialQuality;
- mDepth = ss.depth;
-
- SetCompressionText(FindPaneByID(Caption_Compression), mCodec, mSpatialQuality);
- }
- }
- catch (ExceptionCode inErr)
- {
- ::CloseComponent(ci);
- ReportError(inErr, err_ErrorSettingCompression);
- }
-
- ::CloseComponent(ci);
- break;
- }
-
- default:
-
- LDialogBox::ListenToMessage(inMessage, ioParam);
- }
- }
-
-
- void CPrefsWindow::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
-
- }
-
-
-
-
-
-
-